home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PPC1B3AA.ZIP / INPUTLN.PPS < prev    next >
Text File  |  1996-08-29  |  2KB  |  90 lines

  1. ;----------------------------------------------------------------------------
  2. ; Copyright(C) 1996, The AEGiS Corporation
  3. ;----------------------------------------------------------------------------
  4. ;
  5. ; FUNCTION InputLine()
  6. ;
  7. ; Inputs a line at specified coordinates, with optionnal default line and
  8. ; auto upcase
  9. ;
  10. ; value returned: the line entered by the user
  11. ;
  12. ; inputLinecontrol retains a control code uppon keys used to exit :
  13. ;
  14. ;    ENTER = 0
  15. ;    ESC   = 1
  16. ;    UP    = 2
  17. ;    DOWN  = 3
  18. ;
  19. ;----------------------------------------------------------------------------
  20. #lib
  21. #nouser
  22.  
  23. Declare Function InputLine(Integer Col, Integer Row, Integer StrLen, String DefaultStr, String CharsAllowed, Boolean ConvertToUpcase) String
  24. Integer InputLineControl
  25.  
  26. ;----------------------------------------------------------------------------
  27. Function InputLine(Integer Col, Integer Row, Integer StrLen, String DefaultStr, String CharsAllowed, Boolean ConvertToUpcase) String
  28.  
  29. Integer il_L
  30. String il_Line
  31. String k
  32.  
  33. InputLineControl = 0
  34. AnsiPos Col, Row
  35.  
  36. Print "@X0B"+DefaultStr
  37. il_L = Len(DefaultStr)
  38. il_Line = DefaultStr
  39.  
  40. While (True) Do
  41.     k = Inkey()
  42.     If (ConvertToUpcase) k = Upper(k)
  43.     Select Case k
  44.     
  45.         Case Chr(27)
  46.             InputLine = il_Line;""
  47.             InputLineControl = 1
  48.             Break
  49.             
  50.         Case "UP"
  51.             InputLine = il_line;""
  52.             InputLineControl = 2
  53.             Break
  54.  
  55.         Case "DOWN"
  56.             InputLine = il_line;""
  57.             InputLineControl = 3
  58.             Break
  59.     
  60.         Case Chr(13)
  61.             InputLineControl = 0
  62.             InputLine = il_Line
  63.             Break
  64.             
  65.         Case Chr(8)
  66.             If (il_Line <> "") Then
  67.                 il_Line = Left(il_Line,len(il_Line)-1)
  68.                 Backup 1
  69.                 Print "@X0F."
  70.                 Backup 1
  71.             Endif
  72.         
  73.         Case Else
  74.             If (Len(il_Line) < StrLen & Len(k) = 1 & Asc(k) > 31) Then
  75.                 If (InStr(CharsAllowed, k)) Then
  76.                     If (Right(Il_Line,1) = " ") k = Upper(K)
  77.                     il_Line = il_Line + k
  78.                     Print "@X0B"+k
  79.                     If (len(il_Line) = StrLen) Then
  80.                         InputLine = il_Line
  81.                         Break
  82.                     Endif
  83.                 Endif
  84.             Endif
  85.     
  86.     End Select
  87. Endwhile
  88.  
  89. EndFunc
  90.